<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: mars
  Date: 2019-05-27
  Time: 09:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>index</title>
</head>
<body>
<div>
    <h1>产品列表</h1>
</div>
<div>
    <h3>query table</h3>
    <form:form method="get" action="index" modelAttribute="product">
        <form:label path="id">id</form:label>
        <form:input path="id"/>

        <form:label path="name">name</form:label>
        <form:input path="name"/>

        <form:label path="price">price</form:label>
        <form:input path="price"/>

        <input type="submit" value="submit">
    </form:form>
</div>
<div>
    <div>
        <a href="create" target="_blank">添加商品</a>
    </div>
    <div>

        <table border="1">
            <tr>
                <th>id</th>
                <th>username</th>
                <th>name</th>
                <th>storage</th>
                <th>price</th>
                <th>options</th>
            <%--                <th>created_at</th>--%>
            </tr>
            <c:forEach items="${products}" var="product">
                <tr>
                    <td>${product.id}</td>
                    <td>${product.user.username}</td>
                    <td>${product.name}</td>
                    <td>${product.storage}</td>
                    <td>${product.price}</td>
                    <td>
                        <a href="update?id=${product.id}">修改</a>
                        <a href="delete?id=${product.id}">删除</a>
                        <a href="view?id=${product.id}">详情</a>
                    </td>
                        <%--                    <td>${product.createdAt}</td>--%>
                </tr>
            </c:forEach>
        </table>

    </div>
</div>
</body>
</html>
